<?php
    //include 加载模块组件
    include "library/demo.php";
    //require("demo.php");
    //echo com1();


    //实现接口
    function a1(){
        interface eat{
            //接口里的方法不需要有方法的实现
            public function eat($food);
        }
        //implements 关键字用于表示类实现某个接口
        class Human implements eat{
            public $demo = 100;
            function eat($food){
                echo "eat：".$food;
            }
        }
        $obj =  new Human();
        $obj->eat('稀饭');
        //instanceof 判断摸个实例是否实现了某个接口
        var_dump($obj instanceof eat);
    }
    //a1();

    //抽象类的基本概念
    function a2(){

        abstract class Common{
            abstract public function eat($food);
            public function breath(){
                echo 'breath use the air. <br/>';
            }
        }

        class Human extends Common{
            public function eat($food){
                echo "human eat {$food} \n";
            }
        }
        class Animal extends Common{
            public function eat($food){
                echo "animal eat {$food} \n";
            }
        }
        $human = new Human();
        $animal = new Animal();

        $human->eat('苹果');
        $human->breath();

        $animal->eat('香蕉');
        $animal->breath();

    }
    //a2();

    //clone
    function a3(){
        class Human{
            public $name;
        }

        $a = new Human();
        $a->color = 'pink';

        $b = clone $a;
        echo $b->color;
    }
    //a3();

?>